<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
            text-decoration: none;
        }

        #banner {
            width: 1169px;
            height: 350px;
            overflow: hidden;
            /* border: 3px solid #999; */
            position: relative;
        }

        #imglist {
            width: 7014px;
            height: 350px;
        }

        #imglist li {
            float: left;
            width: 1169px;
            height: 350px;
        }

        img {
            width: 100%;
            height: 100%;
        }

        #iconlist {
            position: absolute;
            right: 20px;
            bottom: 10px;
        }

        #iconlist li {
            float: left;
            width: 25px;
            height: 25px;
            background: #ccc;
            opacity: .5;
            border: 1px solid black;
            border-radius: 50%;
            text-align: center;
            line-height: 25px;
            margin-left: 5px;
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div id="banner">
        <ul id="imglist">
            <li><a href=""><img src="./imgs/banner1.jpg" alt=""></a></li>
            <li><a href=""><img src="./imgs/banner2.jpg" alt=""></a></li>
            <li><a href=""><img src="./imgs/banner3.jpg" alt=""></a></li>
            <li><a href=""><img src="./imgs/banner4.jpg" alt=""></a></li>
            <li><a href=""><img src="./imgs/banner5.jpg" alt=""></a></li>
            <li><a href=""><img src="./imgs/banner1.jpg" alt=""></a></li>
        </ul>
        <ul id="iconlist">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
</body>
<script>
    // 获取元素
    // 获取图片标签
    var imgs = document.getElementById("imglist").getElementsByTagName("li");
    // 获取小圆点
    var icons = document.getElementById("iconlist").getElementsByTagName("li");
    // 初始化图片位置
    var left = 0;
    imglist.style.marginLeft = left + "px";
    // 设置一个计时器
    var timer;

    run()
    


    changeimg()

    function run() {
        if (left <= -5845) {
            imglist.style.marginLeft = 0 + "px";
            left = 0;
        }
        var n = left % 1169 == 0? 1000 : 10;
        changeimg();
        left -= 10;
        setTimeout(run, n);
    }


    function changeimg() {
        imglist.style.marginLeft = left + "px";

    }
</script>

</html>